<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php  $data['leftnav']=2;$this->load->view('admin/header.html',$data)?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/MyJs.js"></script>
<link href="<?php echo base_url()?>common/uploadify/uploadify.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo base_url()?>common/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
    function Success(data) {
        $.Success(data);
    }
    //UE.getEditor('contents');
    $(function () {
        $.validate_down('ajax_form');
    });

    KindEditor.ready(function (K) {
        var editor = K.editor({
            uploadJson: '/common/kindeditor/php/upload_json.php',
            allowFileManager: true
        });
        function initimg() {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#url1').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#imgurl').val(url);
                        K('#img_tag').attr('src', url);
                        editor.hideDialog();
                    }
                });
            });
        }
        K('#img_tag').click(function () {
            initimg();
        });
        K('#imgurl').dblclick(function () {
            initimg();
        });
    });

</script>
<script type="text/javascript">
<?php $timestamp = time();?>
        $(function () {
            $('#file_upload').uploadify({
                'formData': {
                    'timestamp': '<?php echo $timestamp;?>',
                    'token': '<?php echo md5('unique_salt' . $timestamp);?>',

                },
                'swf': '<?php echo base_url()?>common/uploadify/uploadify.swf',
                'uploader': '<?php echo base_url()?>common/kindeditor/php/upload_json_file.php?dir=file',
                'buttonText': '选择课件',
                'auto': false,
                'multi': false,
                'height': '20',
                'width': '80',
                'fileSizeLimit': '200MB',
                'fileTypeExts': '*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.ppt;*.txt;*.rar;*.zip;*.flv;*.swf;*.zip;*.rmvb;*.rm;*.asf;*.avi;*.mid;*.wmv;*.wma;*.wav;*.mp3',
                'buttonClass': 'file_btn',
                'onUploadSuccess': function (file, data, response) {
                    var jsonData = $.parseJSON(data);
                    if (jsonData.error == 0) {
                        $("#downurl").val(jsonData.url);
                        $("#down_name").val(file.name);
                    } else {
                        layer.msg(jsonData.message, { icon: 0 });
                    }
                }
            });
        });
</script>
<style type="text/css">
    .file_btn {
        line-height: 20px;
        text-align: center;
        border: 1px solid #7a7979;
        float:left;
    }
    .up_ul li{float:left;margin-right:20px;height:50px;line-height:50px;}
    .uploadify{top:50%;margin-top:-10px;}
</style>

<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
        <?php $data['crumbsModel']= $this->commonlibraries->GetCrumbs(!empty($downModel)?$downModel->parentid  :$parentid); $this->load->view('admin/crumbs/crumbsview.html',$data);?>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>修改课件</h3>
        <form id="ajax_form" action="<?php echo site_url('admin/down/edit_down')?>" method="post">
            <input id="did" name="did" type="hidden" value="<?php echo !empty($downModel)?$downModel->did:0?>" />
            <input id="parentid" name="parentid" type="hidden" value="<?php echo !empty($downModel)?$downModel->parentid  :$parentid?>" />
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td width="100" align="right">标题</td>
                    <td>
                        <input type="text" id="title" name="title" size="40" class="inpMain" value="<?php echo !empty($downModel)?$downModel->title:""?>" />
                    </td>
                </tr>
               
                <tr>
                    <td width="100" align="right">图片</td>
                    <td style="position:relative;">
                        <img id="img_tag" src="<?php echo !empty($downModel)?$downModel->imgurl:""?>" onerror="this.src='<?php echo base_url('common')?>/images/nopic.png'" style="height:100px;width:100px;cursor:pointer;float:left;"  />
                        <div style="float: left;position: absolute;bottom: 9px;left: 113px;">
                            <input type="text" id="imgurl" name="imgurl" size="40" class="inpMain" value="<?php echo !empty($downModel)?$downModel->imgurl:""?>" readonly="readonly" />
                            <a href="javascript:$.DeleteImg('img_tag','imgurl')" style="margin-left:20px;">删除</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">课件上传</td>
                    <td>
                        <ul class="up_ul">
                            <li style="width:250px;"><input id="file_upload" name="file_upload" type="file" multiple="true"></li>
                            <li><a href="javascript:$('#file_upload').uploadify('upload','*')">上传</a></li>
                            <li><input id="downurl" name="downurl" type="text" value="<?php echo !empty($downModel)?$downModel->downurl:""?>" class="inpMain" style="width:200px;"/></li>
                            <li><input id="down_name" name="down_name" type="hidden" value="" /></li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">权重</td>
                    <td>
                        <input type="text" name="weight" id="weight" size="40" class="inpMain " value="<?php echo !empty($downModel)?$downModel->weight:0?>" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" class="btn" value="<?php echo !empty($downModel)?"修改":"添加"?>" />
                        <input type="button" class="btn" value="返回" onclick="GoBack()" />
                    </td>
                </tr>
            </table>
        </form>
        
    </div>

</div>
